﻿(function () {

    layui.use(["layer", "jquery", "table", "form", "laydate"], function () {
        var layer = layui.layer;
        var $ = layui.jquery;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;

        $(document).ready(function () {
            //$("#btn-Search-OK").click(onSearchBtnClick);
        });

        laydate.render({
            elem: '#txt-Search-Date',
            value: "",
            isInitValue: true,
            showBottom: false
        });

        function getTableQueryParam() {
            return {
                Date: $("#txt-Search-Date").val()
            };
        }

        table.render({
            elem: "#ShopPerformanceTable",
            url: "/ShopPerformance/List",
            height: "full-20", // (10 + 0 + 0 + 10)
            page: false,
            method: "POST",
            where: getTableQueryParam(),
            even: true,
            totalRow: true,
            parseData: function (res) {
                //console.log(res);
                return {
                    "code": res.Success == true ? 0 : -1,
                    "msg": res.Msg,
                    "count": res.Count,
                    "data": res.Data,
                    "totalRow": {
                        count: res.Total
                    }
                };
            },
            cols: [[
                { type: 'numbers', title: 'No.', width: 60, fixed: 'center', totalRow: '{{= d.TOTAL_ROW.count }}' }
                , { field: "Date", width: 120, align: "center", title: "日期" }
                , { field: "OrderAmountTotal", width: 120, align: "center", title: "订单金额总和" }
                , { field: "OrderTotal", width: 120, align: "center", title: "订单总数", totalRow: true }
                , { field: "OrderAmountAvg", width: 120, align: "center", title: "订单均值" }
                , { field: "BonusFee", width: 120, align: "center", title: "平台分红", totalRow: true }
                , { field: "ConsignmentSaleFee", width: 120, align: "center", title: "寄售服务费", totalRow: true }
                , { field: "AmountFrom0KTo1K", width: 80, align: "center", title: "0K - 1K" }
                , { field: "AmountFrom1KTo2K", width: 80, align: "center", title: "1K - 2K" }
                , { field: "AmountFrom2KTo3K", width: 80, align: "center", title: "2K - 3K" }
                , { field: "AmountFrom3KTo4K", width: 80, align: "center", title: "3K - 4K" }
                , { field: "AmountFrom4KTo5K", width: 80, align: "center", title: "4K - 5K" }
                , { field: "AmountFrom5KTo6K", width: 80, align: "center", title: "5K - 6K" }
                , { field: "AmountFrom6KTo7K", width: 80, align: "center", title: "6K - 7K" }
                , { field: "AmountFrom7KTo8K", width: 80, align: "center", title: "7K - 8K" }
                , { field: "AmountFrom8KTo9K", width: 80, align: "center", title: "8K - 9K" }
                , { field: "AmountFrom9KTo10K", width: 80, align: "center", title: "9K - 10K" }
                , { field: "AmountFrom10KTo11K", width: 100, align: "center", title: "10K - 11K" }
                , { field: "AmountFrom11KTo12K", width: 100, align: "center", title: "11K - 12K" }
                , { field: "AmountFrom12KTo13K", width: 100, align: "center", title: "12K - 13K" }
                , { field: "AmountFrom13KTo14K", width: 100, align: "center", title: "13K - 14K" }
                , { field: "AmountFrom14KTo15K", width: 100, align: "center", title: "14K - 15K" }
            ]]
        });

        function onSearchBtnClick() {
            table.reloadData("ShopPerformanceTable", {
                where: getTableQueryParam()
            });
        }
    });

})();